package com.ruoyi.web.controller.tool;

import com.github.pagehelper.PageHelper;
import com.ruoyi.bnt.domain.BntSpecialcolumn;
import com.ruoyi.bnt.domain.BntSpecialcolumninfo;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api("获取主日模块数据")
@RestController
@RequestMapping("/bnt/api/specialcolumn")
public class SpecialcolumnController extends BaseController {
    @Autowired
    private com.ruoyi.bnt.service.IBntSpecialcolumnService bntSpecialcolumnService;

    @Autowired
    private com.ruoyi.bnt.service.IBntSpecialcolumninfoService bntSpecialcolumninfoService;

    @ApiOperation("获取专栏列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageSize", value = "每页显示条数", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageNum", value = "当前显示页数", required = true, dataType = "int", paramType = "query")
    })
    @GetMapping("/list")
    public TableDataInfo list(int pageSize, int pageNum)
    {
        com.ruoyi.bnt.domain.BntSpecialcolumn bntSpecialcolumn =  new com.ruoyi.bnt.domain.BntSpecialcolumn();
        PageHelper.startPage(pageNum,pageSize);
        List<com.ruoyi.bnt.domain.BntSpecialcolumn> list = bntSpecialcolumnService.selectBntSpecialcolumnList(bntSpecialcolumn);
        return getDataTable(list);
    }

    @ApiOperation("根据id获取专栏详细信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "专栏记录id", required = true, dataType = "String", paramType = "query")
    })
    @GetMapping("/info")
    public BntSpecialcolumnEntity info(String id)
    {
        BntSpecialcolumnEntity bntSpecialcolumnEntity = new BntSpecialcolumnEntity();
        com.ruoyi.bnt.domain.BntSpecialcolumn bntSpecialcolumn = bntSpecialcolumnService.selectBntSpecialcolumnById(id);
        bntSpecialcolumnEntity.setBntSpecialcolumn(bntSpecialcolumn);
        com.ruoyi.bnt.domain.BntSpecialcolumninfo bntSpecialcolumninfo =  new com.ruoyi.bnt.domain.BntSpecialcolumninfo();
        bntSpecialcolumninfo.setParentId(id);
        List<com.ruoyi.bnt.domain.BntSpecialcolumninfo> list = bntSpecialcolumninfoService.selectBntSpecialcolumninfoList(bntSpecialcolumninfo);
        bntSpecialcolumnEntity.setBntSpecialcolumninfo(list);
        return bntSpecialcolumnEntity;
    }

    @ApiOperation("根据id获取专栏视频详细信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "专栏视频记录id", required = true, dataType = "String", paramType = "query")
    })
    @GetMapping("/detail")
    public BntSpecialcolumninfo detail(String id)
    {
        com.ruoyi.bnt.domain.BntSpecialcolumninfo bntSpecialcolumninfo =  new com.ruoyi.bnt.domain.BntSpecialcolumninfo();
        bntSpecialcolumninfo = bntSpecialcolumninfoService.selectBntSpecialcolumninfoById(id);
        //访问量加一
        bntSpecialcolumnService.addVisitNum(id);
        return bntSpecialcolumninfo;
    }
}



@ApiModel("专栏详情实体")
class BntSpecialcolumnEntity{
    @ApiModelProperty("主体")
    private com.ruoyi.bnt.domain.BntSpecialcolumn bntSpecialcolumn;

    @ApiModelProperty("详情")
    private List<com.ruoyi.bnt.domain.BntSpecialcolumninfo> bntSpecialcolumninfo;

    public BntSpecialcolumn getBntSpecialcolumn() {
        return bntSpecialcolumn;
    }

    public void setBntSpecialcolumn(BntSpecialcolumn bntSpecialcolumn) {
        this.bntSpecialcolumn = bntSpecialcolumn;
    }

    public List<BntSpecialcolumninfo> getBntSpecialcolumninfo() {
        return bntSpecialcolumninfo;
    }

    public void setBntSpecialcolumninfo(List<BntSpecialcolumninfo> bntSpecialcolumninfo) {
        this.bntSpecialcolumninfo = bntSpecialcolumninfo;
    }
}